struct Solution {}

impl Solution {
  pub fn repeated_string_match(a: String, b: String) -> i32 {
    if b.len() <= a.len() {
      if a.contains(&b) {
        return 1;
      } else if a.repeat(2).contains(&b) {
        return 2;
      } else {
        return -1;
      }
    } else {
      let n = b.len() / a.len();
      let mut template = a.repeat(n);
      if template.contains(&b) {
        return n as i32;
      }
      for i in 1..3 {
        template.push_str(&a);
        if template.contains(&b) {
          return (n + i) as i32;
        }
      }
      -1
    }
  }
}